// 获取企业列表

import type { EnterpriseParams } from "@/types/common"
import type { Datum, Enterprise, EnterpriseDetail, EnterpriseListData, EnterpriseListParams, Industry, RentBuilding, RentParams } from "@/types/enterprise"
import { request } from "@/utils/reuqest"

/**
 * 获取企业列表
 * @param { page, pageSize} params
 * @returns
 */
export const getEnterpriseListAPI = (params: EnterpriseListParams) => {
    return request<EnterpriseListData>('/park/enterprise', 'GET', params)
  }


  // 所在行业接口

  export  const  getIndustryAPI = () => {
    return request<Industry[]>('/park/industry', 'GET')
  }
  // 添加企业接口
  export const addEnterpriseAPI = (data: Enterprise) => {
    return request('/park/enterprise', 'POST', data)
  }

  /**
 * 获取空置中楼宇列表（未租赁）
 * @param {*}
 * @returns
 */
export const getRentBuildListAPI = () => {
  return request<RentBuilding[]>('/park/rent/building', 'GET')
}

// 删除企业
export const deleteEnterpriseAPI = (id: number) => {
  return request(`/park/enterprise/${id}`, 'DELETE')
}

/**
 * 给当前企业添加合同
 */
export const  createRentAPI = (data: RentParams) => {
  return request('/park/enterprise/rent', 'POST', data)
}

// 

/**
 * 获取企业下合同列表
 */
export const getRentListAPI = (id: number) => {
  return request<Datum[]>(`/park/enterprise/rent/${id}`)
}

/**
 * 退租合同
 */
export const outRentAPI = (rentId: string)=> {
  return request(`/park/enterprise/rent/${rentId}`, 'PUT')
}


/**
 * 删除合同
 */
export const deleteRentAPI = (rentId: string)=> {
  return request(`/park/enterprise/rent/${rentId}`, 'DELETE')
}



// 获取企业详情
export const getEnterpriseDetailAPI = (id: number) => {
  return request<EnterpriseDetail>(`/park/enterprise/${id}`, 'GET')
}

// 编辑企业确认修改
export const updateEnterpriseAPI = (data: EnterpriseParams) => {
  return request('/park/enterprise', 'PUT', data)
}
